var pageii = null;
var grid = null;
$(function() {

	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "machine_no",
			name : "机台号",
		}, {
			colkey : "mold_encode",
			name : "模具编号",
		}, {
			colkey : "scheduleTime",
			name : "计划备模时间"
		}, {
			colkey : "marea",
			name : "模具库存区",
		}, {
			colkey : "gunModel",
			name : "料枪型号",
		}, {
			colkey : "gunSpecification",
			name : "料枪规格",
		}, {
			colkey : "gunCount",
			name : "料枪数量",
		}, {
			colkey : "thimbleModel",
			name : "顶针型号",
		}, {
			colkey : "thimbleSpecification",
			name : "顶针规格",
		}, {
			colkey : "thimbleCount",
			name : "顶针数量",
		}, {
			colkey : "elasticModel",
			name : "弹簧型号",
		}, {
			colkey : "elasticCount",
			name : "弹簧数量",
		}, {
			colkey : "beginTime",
			name : "开始"
		}, {
			colkey : "confirmTime",
			name : "结束"
		},{
			colkey : "prepareEndTime",
			name : "备模结束时间"
		},{
			colkey : "area",
			name : "放置区域",
		}, {
			colkey : "mouldstatus",
			name : "模具状态",
			renderData : function(rowindex,data, rowdata, column) {
				if (data==1 || data=="1"){
					return "<font color='red'>已损坏</font>";
				}else if (data==2 || data=="2"){
					return "<font color='blue'>已装模</font>";
				}else if (data==3 || data=="3"){
					return "<font color='lightgreen'>已备模</font>";
				}else if (data==4 || data=="4"){
					return "<font color='#ffb300'>待备模</font>";
				}
			}
		},{
			colkey : "preapreRemark",
			name : "备注",
		}],
		jsonUrl : rootPath + '/prepare/prepare_findByPage.shtml',
		dymCol:true,
		checkbox : true,
		serNumber : false
	});
	$("#editFun").click("click", function() {
		editAccount();
	});
	$("#search").click("click", function() {// 绑定查询按扭
		
		var searchParams = $("#searchForm").serializeJson();
		grid.setOptions({
			data : searchParams
		});
	});
	
});
function editAccount() {
	var cbox = grid.getSelectedCheckbox();
	if (cbox.length > 1 || cbox == "") {
		layer.msg("只能选中一个");
		return;
	}
	pageii = layer.open({
		title : "编辑备模指令表",
		type : 2,
		area : [ "800px", "100%" ],
		content : rootPath + '/prepare/prepare_edit.shtml?id=' + cbox
	});
}
